<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>查询统计管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		
		function getSupply(){
			
				var url = "${ctx }/area/areaChoose/area";
			    layer.open({
			        type: 2,
			        title: '',
			        shadeClose: true,
			        shade: 0.8,
			        area: ['800px', '500px'],
			        content: url 
				});
		}	
		function setReceive(str,code){
			$("#supploy").val(str);
			$("#code").val(code);
		}
		function changes(thi){
			debugger
// 			alert($(thi).val());
			var url = "${ctx}/area/vaccinate/findCompanyName";
			$.ajax({
				url:url,
				data:{"name": $(thi).val()},
				success:function(data){
					debugger
					var html = "";
					var htmll ="";
					var batchnoT = "_";
					$.each(data,function(i,t){
						if(batchnoT.indexOf(t.batchno) <0){
						html += "<option>" + t.batchno + "</option>";
						batchnoT += t.batchno + "_";
						}
					});
					
					 var companyNameT = "_";
					$.each(data,function(i,t){
						if(companyNameT.indexOf(t.bsVaccineInfo.companyName) < 0){
							htmll += "<option>" + t.bsVaccineInfo.companyName + "</option>";
							companyNameT += t.bsVaccineInfo.companyName + "_";
						}
						
					}); 
					$("#batchno").html("<option value=''>--请选择--</option>");
					$("#companyName").html("<option value=''>--请选择--</option>");
					$("#companyName").html(htmll);
					$("#batchno").html(html);
					
				}
			});
		}
		
		function down(){
			top.$.jBox.confirm("确认要导出出入库数据吗？","系统提示",function(v,h,f){
				if(v=="ok"){
					$("#searchForm").attr("action","${ctx}/vaccinate/bsProduct/export");
					$("#searchForm").submit();
				}
			},{buttonsFocus:1});
			top.$('.jbox-body .jbox-icon').css('top','55px');
		}
		
		function post(){
// 			alert($("#code").val());
			var name = $("#vaccinateName").find("option:checked").val();
// 			alert(name);
			var company = $("#companyName").find("option:checked").val();
			var batchno = $("#batchno").find("option:checked").val();
			var furl = "${furl}";
			var url = furl + "/bsOutAndIn/askForVaccinate";
			$.ajax({
				url:url,
				data :{
					"supplyorgName" : $("#supploy").val(),
					"code"	:$("code").val(),
					"vaccineName" : name,
					"companyName" : company,
					"batchno"     : batchno,
					"vaccNum"     : $("#num").val()
					},
				success: function(){
					
				}
			});
		}
		
	</script>

	<style type="text/css">
		.minWidth {
			min-width: 177px;
		}	
	</style>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/vaccinate/bsProduct/">出库疫苗选择</a></li>
	
	</ul>
	<form:form id="searchForm" modelAttribute="bsProduct" action="${ctx}/vaccinate/bsProduct/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<input type="hidden" id="code"/>
		<div class="breadcrumb">
			<table class="table table-bordered">
				
				<tr>
					<th>供货单位</th>
					<td>
						<input type="text" name="supploy" id="supploy" class="input-medium"/>
						<input type="button" id="selectOne" class="btn btn-primary btn-small" onclick="getSupply()" value="选择"/>
					</td>
					
				</tr>
				<tr>
					<th>疫苗名称</th>
					<td>
						<select name="vaccinateName" id="vaccinateName" class="span2 minWidth" onchange="changes(this)">
							<option>--请选择--</option>
							<c:forEach items="${bsVaccines }" var="item">
								<option>${item.name }</option>
							</c:forEach>
						</select>
					</td>
					<th>生产厂商</th>
					<td>
						<select name="type" id="companyName" class="span2 minWidth">
							<option>--请选择--</option>
						</select>
					</td>
					<th>批次</th>
					<td>
						<select name="batchno" id="batchno" class="span2 minWidth" >
							<option>--请选择--</option>
						</select>
					</td>
				</tr>
				<tr>
					<th>数量</th>
					<td colspan="5"><input type="text" id="num" class="input-medium"/></td>
				</tr>
			</table>
		</div>
	
		<ul class="ul-form breadcrumb">
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="button" onclick="post()" value="提交订单"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	
	
</body>
</html>